package com.taoyeshu.modules.sys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.taoyeshu.common.utils.UserContext;
import com.taoyeshu.modules.sys.entity.Resource;
import com.taoyeshu.modules.sys.entity.User;
import com.taoyeshu.modules.sys.service.ResourceService;
import com.taoyeshu.modules.sys.utils.ResUtil;

/**
 * 
 * @描述:首页
 * @作者 :HuanGe
 * @创建日期 :2015年9月28日 上午10:59:06
 *
 */
@Controller
@RequestMapping("/")
public class IndexController {

	@Autowired
	ResourceService resourceService;

	@RequestMapping("/sys/index")
	public String index(Model model) {
		User currentUser = UserContext.get();
		List<Resource> list = resourceService.queryMenuByUserId(currentUser.getId());
		ResUtil resUtil = new ResUtil();
		List<Resource> treeObjects = resUtil.getChildTreeObjects(list, 0);
		model.addAttribute("menuList", treeObjects);
		return "modules/sys/index";
	}

	@RequestMapping("/sys/indexLayout")
	public String indexLayout() {

		return "modules/sys/indexLayout";
	}
}
